package com.hmall.api.client.fallback;

import com.hmall.api.client.ItemClient;
import com.hmall.api.dto.ItemDTO;
import com.hmall.api.dto.OrderDetailDTO;
import com.hmall.common.exception.BizIllegalException;
import com.hmall.common.utils.CollUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;

import java.util.List;

@Slf4j
public class ItemClientFallback implements FallbackFactory<ItemClient> {

    @Override
    public ItemClient create(Throwable cause) {


        return new ItemClient() {
            @Override
            public List<ItemDTO> queryItemByIds(List<Long> ids) {

                log.error("【进入服务降级逻辑了...】   远程调用ItemClient#queryItemByIds方法出现异常，参数：{}", ids);

                return List.of();
            }

            @Override
            public void deductStock(List<OrderDetailDTO> items) {

                log.error("【进入服务降级逻辑了...】   远程调用ItemClient#deductStock方法出现异常，参数：{}", items);

            }
        };
    }
}